﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web.Manage
{
    public partial class PicNewsList : PowerBase
    {
        CJJCH.BLL.T_NET_PicNews bll_pic = new BLL.T_NET_PicNews();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RepeaterDataBind();
            }
        }
        private void RepeaterDataBind()
        {
            IList<CJJCH.Model.T_NET_PicNews> list = new List<CJJCH.Model.T_NET_PicNews>();
            list = bll_pic.GetBackstagePicNewsList();
            this.rptPicNews.DataSource = list;
            this.rptPicNews.DataBind();
        }

        protected void rptPicNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                ((Image)e.Item.FindControl("ImgPicUrl")).ImageUrl = ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).PicUrl;
                ((Label)e.Item.FindControl("lblHrefUrl")).Text = ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).HrefUrl;
                ((Label)e.Item.FindControl("lblOrderNum")).Text = ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).OrderNum.ToString();
                ((Label)e.Item.FindControl("lblIsShow")).Text = ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).IsShow.ToString() == "True" ? "是" : "否";
                ((Label)e.Item.FindControl("lblInstructions")).Text = ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).Instructions.Length > 20 ? ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).Instructions.Substring(1, 20) : ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).Instructions;
                ((Label)e.Item.FindControl("lblInstructions")).ToolTip= ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).Instructions;
                ((HyperLink)e.Item.FindControl("lnkEdit")).NavigateUrl = "PicNewsEdit.aspx?ID=" + ((CJJCH.Model.T_NET_PicNews)e.Item.DataItem).ID.ToString();
                
            }
        }
    }
}